package com.lynn.baseproject

import android.os.Bundle
import android.view.View
import androidx.lifecycle.ViewModelProvider
import com.lynn.baseproject.databinding.ActivityMainBinding
import com.lynn.baseproject.vm.MainViewModel
import com.lynn.common.dialog.CustomAlertDialog
import com.lynn.lib_base.ui.BaseActivity

class MainActivity : BaseActivity<ActivityMainBinding, MainViewModel>(R.layout.activity_main) {

    override fun setData() {
        mBinding?.mainVm = mViewModel
    }

    override fun initView(savedInstanceState: Bundle?) {
        testDialog()
        // 获取网络数据
        mViewModel?.getBiYing()

    }


    fun testDialog() {
        // 第一种方式
        CustomAlertDialog.Builder(this)
            .setTitle("测试标题")
            .setContent("测试内容")

            .build()
            .show()

    }

    fun testDialog2() {
        // 第一种方式
        CustomAlertDialog.Builder(this)
            .show()

    }


    override fun initViewModel(): MainViewModel {
        return ViewModelProvider(this)[MainViewModel::class.java]
    }

    override fun getLayoutRootView(): View {
        return mBinding!!.main
    }

    override fun initParam() {
    }

    override fun initViewObservable() {
        //        mViewModel?.liveData!!.observe(this, object : Observer<BiYingEntity> {
//            override fun onChanged(value: BiYingEntity) {
//                // 设置数据源
//                mViewModel?.liveData?.value = value
//            }
//
//        })
    }

}
